﻿using System;
using System.Data;
using System.Web.UI.WebControls;

namespace BONSAI.Admin.UC
{
    public partial class TypeToursManager : System.Web.UI.UserControl
    {
        /*
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                BindStart();
            }
        }
        public void BindStart()
        {
            //// delete all
            //if (Request.QueryString["zxc"] != null)
            //{
            //    if (Request.QueryString["zxc"].ToString() == "1qwertyuiop")
            //    {
            //        em.Trainee_Delete(0);
            //    }
            //}
            ////=============

            DataTable table = type.LoaiTours_Get(0);
            GridView1.DataSource = table;
            GridView1.DataBind();
         
        }
        
        protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e)
        {
            GridView1.PageIndex = e.NewPageIndex;
            BindStart();
        }

        protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e)
        {
            //string key = GridView1.DataKeys[e.RowIndex].Value.ToString();
            //ad.Advisory_Delete(Int32.Parse(key),0);
            //BindStart();    
        }

        protected void GridView1_RowEditing(object sender, GridViewEditEventArgs e)
        {
            GridView1.EditIndex = e.NewEditIndex;
            BindStart();
        }

        protected void btcapnhat_Click(object sender, EventArgs e)
        {
            if (txtloaitoursTV.Text == "")
            {
                WebMBox.Show("Vui lòng nhập thông tin: Tên loại tours.");
                return;
            }
            if (txtvitri.Text == "")
            {
                WebMBox.Show("Vui lòng nhập vị trí.");
                return;
            }

            #region cập nhật
              type.LoaiTours_Insert(txtloaitoursTV.Text, txtloaitourEN.Text, 3,Int32.Parse(txtvitri.Text));
              WebMBox.Show("Thêm mới thành công.");
            #endregion
              BindStart();
        }

        protected void GridView1_RowCancelingEdit(object sender, GridViewCancelEditEventArgs e)
        {
            GridView1.EditIndex = -1;
            BindStart();
        }

        protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e)
        {
            string key = GridView1.DataKeys[e.RowIndex].Value.ToString();            
            string tenTV = ((TextBox)GridView1.Rows[e.RowIndex].FindControl("TextBox1")).Text;
            string tenEN = ((TextBox)GridView1.Rows[e.RowIndex].FindControl("TextBox2")).Text;
            string viTri = ((TextBox)GridView1.Rows[e.RowIndex].FindControl("TextBox3")).Text;

            if (viTri == "")
            {
                WebMBox.Show("Vui lòng nhập : Vị Trí");
                return;
            }
            
            type.LoaiTours_Update(Int32.Parse(key),tenTV,tenEN,0,Int32.Parse(viTri));
            GridView1.EditIndex = -1;
            BindStart();

        }*/
    }
}